package com.itboye.mengwu.data.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.mengwu.data.interfaces.IAddGoods;
import com.itboye.mengwu.data.interfaces.PrivateInter;
import com.itboye.mengwu.data.model.GetVersionBean;
import com.itboye.mengwu.data.model.GoodsListModel;
import com.itboye.mengwu.data.model.MyTiezibean;
import com.itboye.mengwu.data.model.OrderBean;
import com.itboye.mengwu.data.model.PrivateXinMessgebean;
import com.itboye.mengwu.data.model.SiXinXiangQingModel;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;

public class PrivateRepository extends BaseNetRepository implements PrivateInter<PrivateXinMessgebean> {
	String api = "100";
	public static final String Private = "BY_Message_queryCall";//

	public static final String Delete = "BY_Message_deleteCall";//

	// 私信详情
	public static final String SiXiXiangQing = "BY_Message_detailCall";

	// 发送私信
	public static final String FaSongSiXin = "BY_Message_call";
	
	// 获取app版本
		public static final String GetVersion = "BY_Config_version";

	public PrivateRepository(ICompleteListener listener) {
		// TODO Auto-generated constructor stub
		super(listener);
	}

	@Override
	public void add(PrivateXinMessgebean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(PrivateXinMessgebean model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		
		map.put("curr_uid", model.getCurr_uid());
		map.put("rela_uid", model.getRela_uid());

		(new Builder<String>()).setTypeVerParamsAndReturnClass(Delete, apiVer, map, type)
				.requestListener(new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void update(PrivateXinMessgebean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(PrivateXinMessgebean model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<PrivateXinMessgebean>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", model.getUid());
		map.put("page_size", "10000");
		map.put("page_no", model.getPageNo());
		(new Builder<PrivateXinMessgebean>()).setTypeVerParamsAndReturnClass(Private, apiVer, map, type)
				.requestListener(new BaseSuccessReqListener<PrivateXinMessgebean>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public List<PrivateXinMessgebean> query(PrivateXinMessgebean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void SiXinXiangQing(String curr_uid, String rela_uid, String start_time, String page_no, String page_size) {
		Type type = new TypeToken<SiXinXiangQingModel>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("curr_uid", curr_uid);
		map.put("rela_uid", rela_uid);
		map.put("start_time", start_time);
		map.put("page_no", page_no);
		map.put("page_size", page_size);

		(new Builder<SiXinXiangQingModel>()).setTypeVerParamsAndReturnClass(SiXiXiangQing, apiVer, map, type)
				.requestListener(new BaseSuccessReqListener<SiXinXiangQingModel>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();

	}

	@Override
	public void FaSongSiXin(String uid, String to_uid, String message) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("to_uid", to_uid);
		map.put("message", message);

		(new Builder<String>()).setTypeVerParamsAndReturnClass(FaSongSiXin, apiVer, map, type)
				.requestListener(new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();

	}

	@Override
	public void getVersion() {
		Type type = new TypeToken<GetVersionBean>() {
		}.getType();
		String apiVer = "102";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("api_ver", apiVer);
		map.put("app_type", "android");


		(new Builder<GetVersionBean>()).setTypeVerParamsAndReturnClass(GetVersion, apiVer, map, type)
				.requestListener(new BaseSuccessReqListener<GetVersionBean>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
		
	}

}
